package com.ruoyi.web.controller.fitnesspowers;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fitnesspowers.domain.FitVideoresources;
import com.ruoyi.fitnesspowers.service.IFitVideoresourcesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频管理Controller
 * 
 * @author lzb
 * @date 2023-06-13
 */
@Api("视频管理Controller")
@RestController
@RequestMapping("/fitnesspowers/videoresources")
public class FitVideoresourcesController extends BaseController
{
    @Autowired
    private IFitVideoresourcesService fitVideoresourcesService;

    /**
     * 查询视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:list')")
    @GetMapping("/list")
    @ApiOperation("查询视频管理列表")
    public TableDataInfo list(FitVideoresources fitVideoresources)
    {
        startPage();
        List<FitVideoresources> list = fitVideoresourcesService.selectFitVideoresourcesList(fitVideoresources);
        return getDataTable(list);
    }

    /**
     * 导出视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:export')")
    @Log(title = "视频管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FitVideoresources fitVideoresources)
    {
        List<FitVideoresources> list = fitVideoresourcesService.selectFitVideoresourcesList(fitVideoresources);
        ExcelUtil<FitVideoresources> util = new ExcelUtil<FitVideoresources>(FitVideoresources.class);
        util.exportExcel(response, list, "视频管理数据");
    }

    /**
     * 获取视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:query')")
    @GetMapping(value = "/{fitId}")
    public AjaxResult getInfo(@PathVariable("fitId") Long fitId)
    {
        return success(fitVideoresourcesService.selectFitVideoresourcesByFitId(fitId));
    }

    /**
     * 新增视频管理
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FitVideoresources fitVideoresources)
    {
        return toAjax(fitVideoresourcesService.insertFitVideoresources(fitVideoresources));
    }

    /**
     * 修改视频管理
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FitVideoresources fitVideoresources)
    {
        return toAjax(fitVideoresourcesService.updateFitVideoresources(fitVideoresources));
    }

    /**
     * 删除视频管理
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:videoresources:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fitIds}")
    public AjaxResult remove(@PathVariable Long[] fitIds)
    {
        return toAjax(fitVideoresourcesService.deleteFitVideoresourcesByFitIds(fitIds));
    }
}
